package com.my.study.manage;

import com.my.study.common.ClientConnectServerThread;

import java.util.HashMap;

/**
 * @author Carlos
 * @version 1.0
 * @Description 管理客户端连接服务端线程
 * @date 2021/7/18 14:29
 * @see ClientConnectServerThread
 **/
public class ManageClientConnectServerThread {

    /**
     * 管理连接线程
     * K -> 用户id
     * V -> 客户端连接服务端线程对象
     */
    private static HashMap<String, ClientConnectServerThread> MANAGE_THREAD = new HashMap<>(16);


    /**
     * 添加线程对象
     *
     * @param userId 用户id
     * @param clientConnectServerThread 线程对象
     */
    public static void addClientConnectServerThread(String userId, ClientConnectServerThread clientConnectServerThread) {
        MANAGE_THREAD.put(userId, clientConnectServerThread);
    }

    /**
     * 获取线程对象
     *
     * @param userId 用户id
     * @return
     */
    public static ClientConnectServerThread getClientConnectServerThread(String userId) {
        return MANAGE_THREAD.get(userId);
    }



}
